﻿using System;
using System.Collections.Generic;
using System.Text;

namespace QiAdmin.Core.Utils
{

    /// <summary>
    /// 字符串工具类
    /// </summary>
    public class StringUtil
    {

        private static readonly string ABC = "ABCDEFGHIJKLMNOPQRSTUWVXYZ";
        private static readonly string abc = "abcdefghijklmnopqrstuvwxyz";
        private static readonly string number = "0123456789";
        private static readonly string symbol = "~!@#$%^&*()_+=-[];':,./?";
        public static string GetRandomStr(int len = 10,bool isABC = true, bool isabc = true, bool isnumber = true, bool issymbol = true)
        {
            string str = string.Empty;
            if (isABC)
            {
                str += ABC;
            }
            if (isabc)
            {
                str += abc;
            }

            if (isnumber)
            {
                str += number;
            }
            if (issymbol)
            {
                str += symbol;
            }
            string result = string.Empty;
            Random random = new Random();
            for (int i = 0; i < len; i++)
            {
                result += str[random.Next(0, str.Length - 1)];
            }
            return result;
        }
    }
}
